import json
import os

for path, dirNames, fileNames in os.walk(r"D:\gz\input\20190929", topdown=True):
    # 获取当前目录的所有文件
    for fileName in fileNames:
        filepath = os.path.join(path, fileName)
        lists = []
        with open(filepath, "r", encoding="utf-8") as f:
            for line in f:
                line = line.strip()
                dicts = json.loads(line)
                accnum = dicts["Accession number"]
                lists.append(accnum)

        with open("./AN_big.txt", "a", encoding="utf-8") as f:
            for line in lists:
                f.write(line + "\n")
